<script src="<?php echo base_url(); ?>file/js/accounting.min.js"></script>

<div class="page-title">
  <h2>Detail Penjualan E-Load</h2>
</div>

<table class="general">
  <thead>
    <tr>
      <th>Territory</th>
      <th><?php echo $eload->territory_name; ?></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Tanggal Transaksi</td>
      <td><?php echo date('d F Y', strtotime($eload->sell_date)); ?></td>
    </tr>
    <tr>
      <td>Partner</td>
      <td><?php echo $eload->channel_name; ?></td>
    </tr>
    <tr>
      <td>Sales Name</td>
      <td><?php echo $eload->sales_name; ?></td>
    </tr>
    <tr>
      <td>Nominal</td>
      <td class="nominal"><?php echo $eload->amount; ?></td>
    </tr>
    <tr>
      <td>Status</td>
      <td><?php echo $eload->status; ?></td>
    </tr>
  </tbody>
  <?php if($eload->status == "Unpaid") : ?>
  <tfoot>
    <tr>
      <td></td>
      <td>
        <button class="update">Bayar</button>
      </td>
    </tr>
  </tfoot>
  <?php endif; ?>
</table>


<script>
  $(document).ready(function(){
    $('.nominal').html(accounting.formatMoney( parseFloat($(".nominal").text()), "Rp. ", 2, ".", ","));

    $('button.update').click(function(){
      var eload_id = <?php echo $eload->eload_id; ?>;
      $.post(
          "<?php echo base_url('index.php/sell/close_eload'); ?>", 
          {data:eload_id},
          function(data){
            location.reload();
          }
        );
    });
  });
</script>